package cn.doctor.assistant.pad.ui.hudong;

import android.os.Handler;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;

import com.blunderer.materialdesignlibrary.fragments.ListViewFragment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import cn.doctor.assistant.pad.R;
import cn.doctor.assistant.pad.ui.UI;

/**
 * Created by jiaolf on 2016/3/28.
 * 互动-联系人-列表
 */
public class ContactsListFragment extends ListViewFragment {
    private List<String> mObjects;
    private ArrayAdapter<String> mAdapter;

    @Override
    public ListAdapter getListAdapter() {
        mObjects = new ArrayList<>(Arrays.asList(
                "联系人 1",
                "联系人 2",
                "联系人 3"
        ));
        return (mAdapter = new ArrayAdapter<>(getActivity(), R.layout.listview_row, mObjects));
    }

    @Override
    public boolean useCustomContentView() {
        return false;
    }

    @Override
    public int getCustomContentView() {
        return 0;
    }

    @Override
    public boolean pullToRefreshEnabled() {
        return true;
    }

    @Override
    public int[] getPullToRefreshColorResources() {
        return new int[]{
                R.color.colorPrimary,
                R.color.colorPrimaryDark,
        };
    }

    @Override
    public void onRefresh() {
        UI.showToast("刷新 联系人");
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                setRefreshing(false);
            }
        }, 2000);
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

    }

    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long l) {
        return false;
    }
}
